include("SupportFunctions");


GameEvents = ExposedMembers.GameEvents;
-- Some = ExposedMembers.SEKKA.Some;（没用上，必须注释）


local m_LadicaWonderGreatEngineerPercentage = GlobalParameters.LADICA_GREAT_ENGINEER_PERCENTAGE

-- 成功
function WonderToGreatEngineerPoints1(iX, iY, buildingID, playerID, cityID, iPercentComplete, iUnknown)
    --print(iX, iY, buildingID, playerID, cityID, iPercentComplete, iUnknown)
    local gameSpeed = GameConfiguration.GetGameSpeedType()
    local iSpeedCostMultiplier = GameInfo.GameSpeeds[gameSpeed].CostMultiplier * 0.01
    local player = Players[playerID]
    local city = CityManager.GetCity(playerID, cityID)
    local building = GameInfo.Buildings[buildingID]
    -- print(building.BuildingType)
    if player ~= nil and city ~= nil and building ~= nil then
        local promotion = GameInfo.GovernorPromotions['GOVERNOR_PROMOTION_BUILD']
        local greatEngID = GameInfo.GreatPersonClasses['GREAT_PERSON_CLASS_ENGINEER'].Index
        local greatEngID1 = GameInfo.GreatPersonClasses['GREAT_PERSON_CLASS_SCIENTIST'].Index
        local amount = building.Cost * m_LadicaWonderGreatEngineerPercentage * 0.01 * iSpeedCostMultiplier
        local governor = city:GetAssignedGovernor()
        if governor ~= nil and promotion ~= nil then
            -- print('WonderToGreatEngineerPoints', governor:HasPromotion(promotion.Hash), governor:IsEstablished())
            if governor:IsEstablished() and governor:HasPromotion(promotion.Hash) then
                -- Utils.AddGreatPeoplePoints(playerID, greatEngID, amount)
                GameEvents.AddGreatPeoplePoints.Call(playerID, greatEngID, amount)
                GameEvents.AddGreatPeoplePoints.Call(playerID, greatEngID1, amount)
            end
        end
    end
end

Events.WonderCompleted.Add(WonderToGreatEngineerPoints1)

